package com.heima.wemedia.feign;

import com.heima.apis.wemedia.IWmChannelClient;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WmChannelClient implements IWmChannelClient {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/api/v1/channel/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    @Override
    @GetMapping("/api/v1/channel/del/{id}")
    public ResponseResult deleteChannel(@PathVariable Integer id) {
        return wmChannelService.deleteChannel(id);
    }

    @Override
    @PostMapping("/api/v1/channel/list")
    public ResponseResult listChannels(@RequestBody ChannelDto dto) {
        return wmChannelService.listChannel(dto);
    }

    @Override
    @PostMapping("/api/v1/channel/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.addChannel(wmChannel);
    }

    @PostMapping("/api/v1/channel/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel){
        return wmChannelService.updateChannel(wmChannel);
    }
}